home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_apache.idb / usr / freeware / apache / include / ap_md5.h.z / ap_md5.h
C/C++ Source or Header  |  2001-01-10  |  5KB  |  131 lines

  1. /*
  2.  * This is work is derived from material Copyright RSA Data Security, Inc.
  3.  *
  4.  * The RSA copyright statement and Licence for that original material is
  5.  * included below. This is followed by the Apache copyright statement and
  6.  * licence for the modifications made to that material.
  7.  */
  8.  
  9. /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  10.    rights reserved.
  11.  
  12.    License to copy and use this software is granted provided that it
  13.    is identified as the "RSA Data Security, Inc. MD5 Message-Digest
  14.    Algorithm" in all material mentioning or referencing this software
  15.    or this function.
  16.  
  17.    License is also granted to make and use derivative works provided
  18.    that such works are identified as "derived from the RSA Data
  19.    Security, Inc. MD5 Message-Digest Algorithm" in all material
  20.    mentioning or referencing the derived work.
  21.  
  22.    RSA Data Security, Inc. makes no representations concerning either
  23.    the merchantability of this software or the suitability of this
  24.    software for any particular purpose. It is provided "as is"
  25.    without express or implied warranty of any kind.
  26.  
  27.    These notices must be retained in any copies of any part of this
  28.    documentation and/or software.
  29.  */
  30.  
  31. /* ====================================================================
  32.  * Copyright (c) 1996-1999 The Apache Group.  All rights reserved.
  33.  *
  34.  * Redistribution and use in source and binary forms, with or without
  35.  * modification, are permitted provided that the following conditions
  36.  * are met:
  37.  *
  38.  * 1. Redistributions of source code must retain the above copyright
  39.  *    notice, this list of conditions and the following disclaimer. 
  40.  *
  41.  * 2. Redistributions in binary form must reproduce the above copyright
  42.  *    notice, this list of conditions and the following disclaimer in
  43.  *    the documentation and/or other materials provided with the
  44.  *    distribution.
  45.  *
  46.  * 3. All advertising materials mentioning features or use of this
  47.  *    software must display the following acknowledgment:
  48.  *    "This product includes software developed by the Apache Group
  49.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  50.  *
  51.  * 4. The names "Apache Server" and "Apache Group" must not be used to
  52.  *    endorse or promote products derived from this software without
  53.  *    prior written permission. For written permission, please contact
  54.  *    apache@apache.org.
  55.  *
  56.  * 5. Products derived from this software may not be called "Apache"
  57.  *    nor may "Apache" appear in their names without prior written
  58.  *    permission of the Apache Group.
  59.  *
  60.  * 6. Redistributions of any form whatsoever must retain the following
  61.  *    acknowledgment:
  62.  *    "This product includes software developed by the Apache Group
  63.  *    for use in the Apache HTTP server project (http://www.apache.org/)."
  64.  *
  65.  * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  66.  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  67.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  68.  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  69.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  70.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  71.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  72.  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  73.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  74.  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  75.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  76.  * OF THE POSSIBILITY OF SUCH DAMAGE.
  77.  * ====================================================================
  78.  *
  79.  * This software consists of voluntary contributions made by many
  80.  * individuals on behalf of the Apache Group and was originally based
  81.  * on public domain software written at the National Center for
  82.  * Supercomputing Applications, University of Illinois, Urbana-Champaign.
  83.  * For more information on the Apache Group and the Apache HTTP server
  84.  * project, please see <http://www.apache.org/>.
  85.  *
  86.  */
  87.  
  88. #ifndef APACHE_MD5_H
  89. #define APACHE_MD5_H
  90.  
  91. #ifdef __cplusplus
  92. extern "C" {
  93. #endif
  94.  
  95. /* MD5.H - header file for MD5C.C */
  96.  
  97. #define MD5_DIGESTSIZE 16
  98.  
  99. /* UINT4 defines a four byte word */
  100. typedef unsigned int UINT4;
  101.  
  102. /* MD5 context. */
  103. typedef struct {
  104.     UINT4 state[4];        /* state (ABCD) */
  105.     UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
  106.     unsigned char buffer[64];    /* input buffer */
  107. } AP_MD5_CTX;
  108.  
  109. /*
  110.  * Define the Magic String prefix that identifies a password as being
  111.  * hashed using our algorithm.
  112.  */
  113. #define AP_MD5PW_ID "$apr1$"
  114. #define AP_MD5PW_IDLEN 6
  115.  
  116. API_EXPORT(void) ap_MD5Init(AP_MD5_CTX *context);
  117. API_EXPORT(void) ap_MD5Update(AP_MD5_CTX *context, const unsigned char *input,
  118.                   unsigned int inputLen);
  119. API_EXPORT(void) ap_MD5Final(unsigned char digest[MD5_DIGESTSIZE],
  120.                  AP_MD5_CTX *context);
  121. API_EXPORT(void) ap_MD5Encode(const unsigned char *password,
  122.                   const unsigned char *salt,
  123.                   char *result, size_t nbytes);
  124. API_EXPORT(void) ap_to64(char *s, unsigned long v, int n);
  125.  
  126. #ifdef __cplusplus
  127. }
  128. #endif
  129.  
  130. #endif    /* !APACHE_MD5_H */
  131.